<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Inbox</title>
  <style>
    /* 重置默认样式，以避免浏览器差异 */
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    /* 基本样式设置 */
    body {
      font-family: Arial, sans-serif;
      color: #333;
      background-color: #f2f2f2;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100vh;
      margin: 0;
      padding: 20px;
    }

    h1 {
      text-align: center;
      color: #666;
      margin-bottom: 20px;
    }

    ul {
      list-style-type: none;
      padding: 20px;
      background-color: #fff;
      border-radius: 5px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }

    li {
      margin-bottom: 10px;
    }

    li a {
      display: block;
      padding: 10px;
      text-decoration: none;
      background-color: #f2f2f2;
      border-radius: 5px;
      transition: background-color 0.3s ease;
    }

    li a:hover {
      background-color: #e6e6e6;
    }
  </style>
</head>
<body>
  <h1>Inbox</h1>
  <a href="#" onclick="window.electron.navigate('writeEmail')">
    <botton>
      New Email
    </botton>
  </a>
  <ul id="inbox">
  </ul>
  <script>
    function viewEmail(id) {
      localStorage.setItem('emailId', id);
      window.electron.navigate(`email`);
    }
    window.electronAPI.send('set-email-list', {});
    window.electronAPI.receive('get-email-list', (emailData) => {
      console.log(emailData)
      emailData.forEach(email => {
        document.getElementById('inbox').innerHTML += `<li><a href="#" onclick="viewEmail(${email.id})">Email ${email.subject}-${email.id}</a></li>`
      })
    });
  </script>
</body>
</html>
